const fs = require('fs')
// 封装promise对象
const readFilePromise = (fileUrl)=>{
	const promise = new Promise((resolve, reject) => {
		//封装异步读文件
		fs.readFile(fileUrl, 'utf-8', function (err, data) {
			if (err) {
				reject(err) //失败结果
				return
			}
			resolve(data.toString()) // 处理成功结果
		})
	})

	return promise
	
}


const promise = readFilePromise('demo2.txt')

promise.then(data => console.log(data)).catch(err => console.log(err))